<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>

<body>
    <div id="app">
        <!-- :style可以是对象,键名就是样式属性名，值就是样式值 -->
        <p :style="{color:bool?'red':'blue',backgroundColor:'tan'}">111</p>

        <!-- :style可以是数组，里面带多个对象且对象带键值对. -->
        <div :style="[{color:bool?'red':'blue', backgroundColor:color}, {width}]">222</div>
    </div>

    <script>
        new Vue({
            el: '#app',
            data: {
                bool: false,
                color: 'yellow',
                width: '100px'
            }
        })
    </script>
</body>

</html>